import { defHttp } from '@/utils/http/axios';
import { UserMonthScheduleCount, UserShortcutMenuInfo } from './model';
import { ID } from '@/api/base';
import { LoginLog } from '@/api/monitor/logininfo/model';
import { OperateLog } from '@/api/monitor/operlog/model';

enum Api {
  getUserShortcutMenuInfo = '/system/user/profile/getUserShortcutMenuInfo',
  setUserShortcutMenuInfo = '/system/user/profile/setUserShortcutMenuInfo',
  setUserShortcutMenuPath = '/system/user/profile/setUserShortcutMenuPath',
  getUserMonthScheduleCount = '/system/user/profile/getUserMonthScheduleCount',
  getUserDayScheduleList = '/system/user/profile/getUserDayScheduleList',
  getUserLoginLogList = '/system/user/profile/loginLog',
  getUserOperateLogList = '/system/user/profile/operateLog',
}

export function getUserShortcutMenuInfo() {
  return defHttp.get<UserShortcutMenuInfo[]>({ url: Api.getUserShortcutMenuInfo });
}

export function setUserShortcutMenuInfo(menuId: ID) {
  return defHttp.get(
    { url: Api.setUserShortcutMenuInfo + '/' + menuId },
    { errorMessageMode: 'none' },
  );
}

export function setUserShortcutMenuPath(path: ID) {
  return defHttp.post<void>(
    { url: Api.setUserShortcutMenuPath, data: { path } },
    { errorMessageMode: 'none' },
  );
}

/**
 * @description: 获取用户日程
 */
export function getUserMonthScheduleCount(year: string | number, month: string | number) {
  return defHttp.get<UserMonthScheduleCount>(
    { url: Api.getUserMonthScheduleCount, params: { year, month } },
    { errorMessageMode: 'none' },
  );
}

export function getUserDayScheduleList(date: string) {
  return defHttp.post<void>({ url: Api.getUserDayScheduleList, data: { date } });
}

/**
 * @description: 获取用户 登录日志
 */
export function getUserLoginLogList() {
  return defHttp.get<LoginLog>({ url: Api.getUserLoginLogList }, { errorMessageMode: 'none' });
}

/**
 * @description: 获取用户 操作日志
 */
export function getUserOperateLogList() {
  return defHttp.get<OperateLog>({ url: Api.getUserOperateLogList }, { errorMessageMode: 'none' });
}
